<?php
Class admin_logonController Extends baseController {

	public function index() { 
		$this->registry->template->show('admin/logon');
	}
	
	public function login(){ 
		$username = $_POST['tusername'];
		$pass = md5($_POST['tpass']);
		$userModel = new user();
		$user = $userModel->checkLoginAdmin($username,$pass);
		if($user){
			$_SESSION['user'] = $user;
			header('location:'.__URL_BASE.'admin/trang-chu.html');
			exit;
		}
		else{
			$this->registry->template->fail = 'Thông tin đăng nhập không đúng';
			$this->registry->template->show('admin/logon');
		}
	}
	
	public function logout(){
		unset($_SESSION['user']);
		header('location:'.__URL_BASE.'index.php?rt=admin_logon');
		exit;
	}
}
?>
